package com.wang.controller;

import com.wang.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderNacosController {
    // public static final String PAYMENT_URL = "http://nacos-payment-provider";
    // @Resource
    // private RestTemplate restTemplate;
    //
    //
    // @GetMapping("/consumer/payment/nacos/{id}")
    // public String getPayment(@PathVariable("id") Integer id) {
    //     log.info("********查询的id：" + id);
    //     //getForObject两个参数：请求地址，返回的对象类型
    //     return restTemplate.getForObject(PAYMENT_URL + "/payment/nacos/" + id, String.class);
    // }


    @Resource
    private PaymentFeignService paymentFeignService;
    @GetMapping("/consumer/payment/nacos/{id}")
    public String getPayment(@PathVariable("id") Integer id) {
        log.info("********查询的id：" + id);
        return paymentFeignService.getPayment(id);
    }
}